var fs = require('fs');

var ws = fs.createWriteStream("createWriteStream.txt");

console.log(i); // undefined

for (var i=0; i<100; i++) {
  ws.write(`第${i}行\n`);
}

console.log(i); // 100
// 疑问：流何时关闭
ws.end();

// ws.write("第三行\n"); // 此时流已关闭，写入失败

ws.once('finish', function(){
  console.log('stream is finished!');
})

